# %%
import torch
import torchvision
import torch.nn as nn
from model import LeNet
import torch.optim as optim
import torchvision.transforms as transforms
from torch.nn.utils import prune
import os
import copy
import math
import random
import argparse
import numpy as np

def radar_sim(n):
    # 随机生成车速 vx, vy, vz
    vx = random.uniform(-10, 10)
    vy = random.uniform(-10, 10)
    vz = random.uniform(-1, 1)
    # 随机生成 n 个目标点 (x, y, z, v)
    n = 100
    points = np.zeros((n, 5))
    for i in range(n):
        points[i] = [random.uniform(0, 100), random.uniform(-50, 50), random.uniform(-2, 2), 0.0, 0.0]
    # 计算每个点 (x, y, z) 对应的径向速度 vr
    for point in points:
        x, y, z, _, _ = point
        r = (x ** 2 + y ** 2 + z ** 2) ** 0.5
        prob = random.uniform(-10, 3)
        if prob > 0:
            tem = random.uniform(-10, 10)
            vr_noise = random.uniform(0.8, 3.3) * (math.exp(tem) - math.exp(-tem)) / (math.exp(tem) +math.exp(-tem)) # 运动信息
        else:
            vr_noise = random.uniform(-0.05, 0.05)  # 运动信息
        vr = x / r * vx + y / r * vy + z / r * vz + vr_noise
        point[3] = vr
        if vr_noise > 0.25 or vr_noise< -0.25:
            point[4] = 1.0
    return  points,np.array([vx,vy,vz])


if __name__ == '__main__':

    for i in range(5000):
        points ,carspeed = radar_sim(0)
        np.savetxt(r'/home/zwh/Desktop/testAndlearn/learn/DeepLearn学习/deep-learning-for-image-processing/pytorch_classification/FrogEye/data/train/{}.txt'.format(100000+i), points, fmt='%.3e')

